sgdk
sprite_eng.h File Reference

Sprite engine. More...

#include "vdp_pal.h"
#include "vdp_tile.h"
#include "vdp_spr.h"

Go to the source code of this file.

Classes

struct  VDPSprite
struct  FrameSprite
struct  AnimationFrame
struct  Animation
struct  SpriteDefinition
struct  Sprite

Defines

#define SPRITE_CACHE_SIZE   128
#define COLLISION_TYPE_NONE   0
#define COLLISION_TYPE_BOX   1
#define COLLISION_TYPE_CIRCLE   2

Functions

void SPR_init (u16 cacheSize)
 Init the Sprite engine.
void SPR_end ()
 End the Sprite engine.
u16 SPR_isInitialized ()
 FALSE if sprite cache engine is not initialized.
void SPR_initSprite (Sprite *sprite, SpriteDefinition *spriteDef, s16 x, s16 y, u16 attribut)
 Initialize the specified Sprite.
By default a sprite use automatic VRAM tile allocation but you can fix it by using the SPR_setVRAMTileIndex(..) method.
void SPR_setPosition (Sprite *sprite, s16 x, s16 y)
 Set sprite position.
void SPR_setAttribut (Sprite *sprite, u16 attribut)
 Set sprite attribut.
void SPR_setAnimAndFrame (Sprite *sprite, s16 anim, s16 frame)
 Set current sprite animation and frame.
void SPR_setAnim (Sprite *sprite, s16 anim)
 Set current sprite animation.
void SPR_setFrame (Sprite *sprite, s16 frame)
 Set current sprite frame.
void SPR_nextFrame (Sprite *sprite)
 Pass to the next sprite frame.
void SPR_setVRAMTileIndex (Sprite *sprite, s16 index)
 Set the VRAM tile position for this sprite.
void SPR_setAlwaysVisible (Sprite *sprite, u16 value)
 Set the always visible flag this sprite.
By setting it to TRUE the sprite is considered as always visible
and won't require any visibility computation.
void SPR_setNeverVisible (Sprite *sprite, u16 value)
 Set the never visible flag this sprite.
By setting it to TRUE the sprite is considered as always hidden
and won't be displayed.
void SPR_clear ()
 Test if specified sprites are in collision.
void SPR_update (Sprite *sprites, u16 num)
 Update and display the specified list of sprite.
This actually prepare the list cache and send it to the hardware (VDP) at Vint.

Detailed Description

Sprite engine.

Author:
Stephane Dallongeville
Date:
10/2013

Sprite engine providing advanced sprites manipulation and operations.
This unit use both the tile cache engine (see tilecache.h file for more info)
and the Sega Genesis VDP sprite capabilities (see vdp_spr.h file for more info).


Define Documentation

#define COLLISION_TYPE_BOX   1

Bouding box collision tpye

#define COLLISION_TYPE_CIRCLE   2

Round circle collision tpye

#define COLLISION_TYPE_NONE   0

No collision tpye

#define SPRITE_CACHE_SIZE   128

Maximum number of sprite in the cache


Function Documentation

void SPR_clear ( )

Test if specified sprites are in collision.

Parameters:
sprite1first sprite.
sprite2second sprite.
Returns:
TRUE if sprite1 and sprite2 are in collision, FALSE otherwise.

Clear all displayed sprites.
This actually clear the list cache and send it to the hardware (VDP) at Vint.

void SPR_end ( )

End the Sprite engine.

End the sprite engine.
This actually release memory allocated for sprite cache and release the tile cache engine if it was started by Sprite engine.

void SPR_init ( u16  cacheSize)

Init the Sprite engine.

Parameters:
cacheSizesize of the tile cache (in tile) for the automatic tile allocation.
If set to 0 the default size is used (384 tiles)

Initialize the sprite engine.
This actually allocate memory for sprite cache and initialize the tile cache engine if this is not alreay done.

void SPR_initSprite ( Sprite sprite,
SpriteDefinition spriteDef,
s16  x,
s16  y,
u16  attribut 
)

Initialize the specified Sprite.
By default a sprite use automatic VRAM tile allocation but you can fix it by using the SPR_setVRAMTileIndex(..) method.

Parameters:
spriteSprite to initialize.
spriteDefthe SpriteDefinition data to assign to this sprite.
xdefault X position.
ydefault Y position.
attributsprite attribut (see TILE_ATTR() macro).
void SPR_nextFrame ( Sprite sprite)

Pass to the next sprite frame.

Parameters:
spriteSprite to pass to next frame for
void SPR_setAlwaysVisible ( Sprite sprite,
u16  value 
)

Set the always visible flag this sprite.
By setting it to TRUE the sprite is considered as always visible
and won't require any visibility computation.

Parameters:
spriteSprite to set the always visible flag
valueThe always visible flag value (TRUE or FALSE)
See also:
SPR_setNeverVisible(..)
void SPR_setAnim ( Sprite sprite,
s16  anim 
)

Set current sprite animation.

Parameters:
spriteSprite to set animation for
animanimation index to set.
void SPR_setAnimAndFrame ( Sprite sprite,
s16  anim,
s16  frame 
)

Set current sprite animation and frame.

Parameters:
spriteSprite to set animation and frame for
animanimation index to set
frameframe index to set
void SPR_setAttribut ( Sprite sprite,
u16  attribut 
)

Set sprite attribut.

Parameters:
spriteSprite to set attribut for
attributattribut (see TILE_ATTRIBUT() macro)
void SPR_setFrame ( Sprite sprite,
s16  frame 
)

Set current sprite frame.

Parameters:
spriteSprite to set frame for
frameframe index to set.
void SPR_setNeverVisible ( Sprite sprite,
u16  value 
)

Set the never visible flag this sprite.
By setting it to TRUE the sprite is considered as always hidden
and won't be displayed.

Parameters:
spriteSprite to set the never visible flag
valueThe never visible flag value (TRUE or FALSE)
See also:
SPR_setAlwaysVisible(..)
void SPR_setPosition ( Sprite sprite,
s16  x,
s16  y 
)

Set sprite position.

Parameters:
spriteSprite to set position for
xX position
yY position
void SPR_setVRAMTileIndex ( Sprite sprite,
s16  index 
)

Set the VRAM tile position for this sprite.

Parameters:
spriteSprite to set the VRAM tile position for
indexthe tile position in VRAM where we will upload the sprite tiles.
Set to -1 for automatic allocation (default).
void SPR_update ( Sprite sprites,
u16  num 
)

Update and display the specified list of sprite.
This actually prepare the list cache and send it to the hardware (VDP) at Vint.

Parameters:
spritessprites we want to prepare and display.
numnumber of sprites in the list.
 All Classes Files Functions Variables Typedefs Enumerations Defines